/**
*┌──────────────────────────────────────────────────────────────┐
*│　描    述：SysLog仓储                                              
*│　作    者：sys                                            
*│　创建时间：2020-11-06 14:41:01  
*│　说    明：代码生成器生成   
*└──────────────────────────────────────────────────────────────┘
*/
using SXFramWork.Core;
using SXFramWork.Model;
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Threading.Tasks;

namespace SXFramWork.Repository
{
    public class SysLogRepository:RepositoryAbstract<SysLogEntity>,ISysLogRepository
    {
        public SysLogRepository(IDbContext dbContext) :base(dbContext)
        {
          
        }

        public async Task<List<SysLogEntity>> Query(LogQueryModel model)
        {
            var sql = @"SELECT
                       Id
                      ,[UserName]
                      ,[CreateTime]
                      ,[IP]
                      ,[Browser]
                      ,[Result]
                      ,[Operation]
                      ,[Message]
                      ,[ApiUrl],
                      elapsedMilliseconds
                  FROM [SysLog] where 1=1 ";
            //dynamic obj = new ExpandoObject();
            string where = string.Empty;
            if (model.Type >= 0)
            {
                where += " and type=@type";
               // obj.orgId = model.Type;
            }
            //模糊查询
            Dictionary<string, object> check = new Dictionary<string, object>();
            if (!model.UserName.IsNull())
            {
                check.Add("UserName", model.UserName);
            }
            return await FromSql.GetPageListAsync(sql, model, check, where,new {type=model.Type });
        }
    }
}